package com.daidai.controller;

import com.daidai.exception.SystemException;
import com.daidai.exception.BussinessException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException ex){
        return new Result(null, ex.getCode(), ex.getMessage());
    }

    @ExceptionHandler(BussinessException.class)
    public Result doBusinessException(BussinessException ex){
        return new Result(null, ex.getCode(), ex.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){
        return new Result(null, Code.SYSTEM_UNKNOW_ERR, "系统繁忙！");
    }

}
